﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Greve
{
    public partial class Login : Form
    {
        String user;
        String password;
        String correct = "admin";
        String correct_pass = "password";
		String correct_pass2 = "password2";
        public Login()
        {
            InitializeComponent();
			button1.Focus();
        }
		private void OK_button()
		{

			user = textbox_username.Text;
			password = textBox_pass.Text;
			if (password == correct_pass)
			{
				this.Hide();
                new Greve.Forms.ConnectToServer("judge",user).ShowDialog();
				//new Judge_ui().ShowDialog();
				this.Close();
				
			}
			else if (user == correct && password == correct_pass2)
			{
				this.Hide();
				new CupManager().ShowDialog();
				this.Close();
			}
			else
			{
				MessageBox.Show("Wrong password!");
				textBox_pass.ResetText();
			}
		}

        private void button1_Click(object sender, EventArgs e)
        {
			OK_button();
        }


		private void CheckEnter(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == (char)13)
			{
				textBox_pass.Focus();
			}
		}
        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Login_Load(object sender, EventArgs e)
        {

        }

		private void button3_Click(object sender, EventArgs e)
		{
			this.Hide();
            new Greve.Forms.ConnectToServer("resultat","null").ShowDialog();
			//new Resultat().ShowDialog();
			this.Close();
		
		}

		private void CheckEnter2(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == (char)13)
			{
				OK_button();
			}
		}


		private void textBox_pass_TextChanged(object sender, EventArgs e)
		{

		}
    }
}
